import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Hello } from './entities/hello.entity';

@Injectable()
export class HelloService {
  // 注入 Repository
  constructor(
    @InjectRepository(Hello)
    private readonly helloRepository: Repository<Hello>,
  ) {}

  // 获取消息
  findAll(): Promise<Hello[]> {
    return this.helloRepository.find();
  }

  // 获取消息
  getMessage(name: string): string {
    return `Hello ${name}!`;
  }

  // 上传文件
  uploadFile(file: Express.Multer.File): string {
    return `文件上传成功: ${file.originalname}`;
  }
}
